﻿package mortal.game.view.closedBetaGiftBag
{
    import __AS3__.vec.*;
    import com.mui.events.*;
    import com.mui.utils.*;
    import extend.language.*;
    import mortal.component.window.*;
    import mortal.game.cache.*;
    import mortal.game.view.closedBetaGiftBagNew.panel.*;
    import mortal.game.view.common.*;
    import mortal.game.view.wizard.*;
    import mortal.mvc.interfaces.*;

    public class ClosedBetaGiftBagModule extends BaseWindow
    {
        private var _tabData:Array;
        private var _tabBar:GTabarNew;
        private var _clsVec:Vector.<Class>;
        private var _curSelView:ClosedBetaBasePanel;
        private var _curSelIndex:int = 0;

        public function ClosedBetaGiftBagModule(param1:ILayer = null)
        {
            super(param1);
            setSize(899, 613 - 30);
            title = Language.getString(90401);
            return;
        }// end function

        private function initTabData() : void
        {
            this._tabData = Language.getArray(90100);
            this._tabData[0].num = Cache.instance.closedBetaLevelGift.numReceive;
            this._tabData[1].num = Cache.instance.closedBetaOnlineGift.numReceive;
            this._tabData[2].num = Cache.instance.closedBetaTimingGift.numReceive;
            return;
        }// end function

        private function initClsVec() : void
        {
            if (!this._clsVec)
            {
                this._clsVec = new Vector.<Class>;
                this._clsVec.push(ClosedBetaLevelGiftView);
                this._clsVec.push(ClosedBetaOnlineGiftPanel);
                this._clsVec.push(ClosedBetaTimingGiftPanel);
            }
            return;
        }// end function

        public function setDefaultPanel() : void
        {
            var _loc_1:* = Cache.instance.closedBetaGiftBag.firstReceiveTagIndex;
            this._tabBar.selectedIndex = Cache.instance.closedBetaGiftBag.firstReceiveTagIndex;
            this._curSelIndex = _loc_1;
            this.updatePanel();
            return;
        }// end function

        private function onSwitchTab(event:MuiEvent = null) : void
        {
            var _loc_2:* = this._tabBar.selectedIndex;
            if (this._curSelIndex != _loc_2)
            {
                this._curSelIndex = _loc_2;
                this.updatePanel();
            }
            return;
        }// end function

        private function updatePanel() : void
        {
            if (this._curSelView && !this._curSelView.isDisposed)
            {
                this._curSelView.dispose();
            }
            var _loc_1:* = this._clsVec[this._curSelIndex];
            this._curSelView = UICompomentPool.getUICompoment(_loc_1);
            this._curSelView.y = 30;
            this.addChild(this._curSelView);
            this.refresh();
            return;
        }// end function

        public function get curSelView() : ClosedBetaBasePanel
        {
            return this._curSelView;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this.initClsVec();
            this.initTabData();
            this._tabBar = UIFactory.gTabBarNew(0, 32, this._tabData, 900, 600, 65 + 40, 26, this, this.onSwitchTab, "TabButtonNew");
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._tabBar.dispose(param1);
            this._tabBar = null;
            return;
        }// end function

        public function refresh() : void
        {
            this.initTabData();
            if (this._tabBar)
            {
                this._tabBar.dataProvider = this._tabData;
            }
            return;
        }// end function

    }
}
